import { post, get } from '../utils/request';

/**
 * 用户认证相关API
 */

// 发送短信验证码
export const sendSmsVerifycode = (phone: string) => {
  return post('/v1/sendSmsVerifycode', { phone });
};

// 验证码登录
export const verifyCodeLogin = (data: { phone: string; code: string }) => {
  return post('/v1/app/user/login', {
    ...data,
    login_type: 'smsLogin' // 写死
  });
};

// 密码登录
export const passwordLogin = (data: { phone: string; password: string }) => {
  return post('/v1/app/user/login', {
    ...data,
    login_type: 'phoneAndPasswordLogin' // 写死
  });
};

// 用户登出
export const logout = () => {
  return post('/v1/app/user/logout');
};

// 获取用户信息
export const getUserInfo = () => {
  return get('/v1/app/user/info');
};

// 刷新token
export const refreshToken = (token: string) => {
  return post('/v1/app/user/refresh', { token });
};
